package logic

import (
	"context"
	"errors"
	"regist-detail-sys/model/mysql"

	"regist-detail-sys/registrpc/internal/svc"
	"regist-detail-sys/registrpc/registrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type RegisShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRegisShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisShowLogic {
	return &RegisShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 挂号详情
func (l *RegisShowLogic) RegisShow(in *registrpc.RegisShowRequest) (*registrpc.RegisShowResponse, error) {
	// todo: add your logic here and delete this line

	var patient mysql.Patient

	err := patient.PatientShowById(mysql.DB, in.PatientId)
	if err != nil {
		return nil, errors.New("查询不到")
	}

	return &registrpc.RegisShowResponse{
		PatientId: in.PatientId,
		Name:      patient.Name,
		CarNum:    patient.CarNum,
		Phone:     patient.Phone,
		Address:   patient.Address,
	}, nil
}
